-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow signal bootstrap sends to commands on cancel to be customized #1390
Allow signal bootstrap sends to commands on cancel to be customized #1390
Conversation
Currently bootstrap sends a `SIGTERM` to commands when it, itself, is interrupted. This adds `cancel-signal` which accepts signals in the form of SIGTERM, SIGHUP, etc. This is the same config that `start` accepts, and is based on the PR that added that feature: #1041 Finally, `start` passes its `cancel-signal` to `bootstrap`, to prevent having to customize the `bootstrap-script`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution @brentleyjones 🙏🏻
This is a straightforward implementation and safe improvement to current behaviour. It might be worth adding a test around to confirm the configuration signal reaches the shell configuration, but otherwise these are all well tested corners of the code.
We'll carry out our intention to transition the defaults to SIGINT
in the future, but for now, it makes sense to add the configuration option and allow us to experiment with the finer details of how the change will affect users. I'm very appreciative of your well-reasoned need for using this to safely dispose of process groups, this is helpful for communicating why we will make this change in the next major release.
Excuse me while I think this through “out loud”… The existing JobRunner TL;DR: on job cancellation, the job runner sends the bootstrap process (and its child processes?) the configured signal. This PR introduces to Bootstrap TL;DR: bootstrap signal handler calls So I think the intention of this PR is to make So … 👍🏼 My only feedback is that I think we should pass |
clicommand/agent_start.go
Outdated
"%s bootstrap --cancel-signal %s", | ||
shellwords.Quote(os.Args[0]), | ||
cfg.CancelSignal, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the part that I think should be propagated via environment rather than CLI args. I think we have other options passing through via environment, perhaps most recently added by @ticky?
Something else we should think about is either test coverage, or at least a before/after proof copied/pasted into this comment thread showing that this results in the configured signal being sent to the actual commands being run within the bootstrap. |
That was what I tried first, but it wasn't being passed through. I would be fine with it working that way, the direct argument call was the easiest for me to get it to work. |
I wasn't sure how to do the tests, but I would be supportive of that. I can instead create a little example using traps that shows which signals are being sent (it was how I noticed the issue to begin with). Just lmk. |
Sorry for the silence @brentleyjones… I've pushed a commit to this PR which propagates the option to bootstrap via I was also unsure how to write tests for this, so I did some local testing. I built a simple binary that reports which signal it was killed by. I ran
|
thanks @brentleyjones ❤️ |
Thanks! |
Currently bootstrap sends a
SIGTERM
to commands when it, itself, is interrupted.This adds
cancel-signal
which accepts signals in the form of SIGTERM, SIGHUP, etc.This is the same config that
start
accepts, and is based on the PR that added that feature: #1041Finally,
start
passes itscancel-signal
tobootstrap
, to prevent having to customize thebootstrap-script
.